{extend name="common/main"}

{block name="css"}
<!-- 本页面需要额外添加的css请在此处添加 -->
{/block}
{block name="body"}
<body>
 <header>
      <div class="tab_nav">
        <div class="header">
          <div class="h-left"><a class="sb-back" href="javascript:history.back(-1)" title="返回"></a></div>
          <div class="h-mid">我的留言</div>
          <div class="h-right">
            <aside class="top_bar">
              <div onClick="show_menu();$('#close_btn').addClass('hid');" id="show_more"><a href="javascript:;"></a> </div>
            </aside>
          </div>
        </div>
      </div>
</header>
 {include file="common/goods_nav"}
<div id="tbh5v0">
<div class="liuyan">
    <div class="liuyan_list">
      {foreach name="message" item="vo"}
	      <dl>
	        <dt><span class="title">{$msg_type[$vo['msg_type']]}</span>{$vo.msg_title}</dt>
	        <dd></dd>
	        <dd><span>{$vo.msg_content}</span><font></font></dd>
	        <span class="liuyan_time">{$vo.msg_time|date='Y-m-d H:i:s',###}</span>  
	      </dl>   
	  {/foreach}
    </div>
    {notempty name="message"}
    <div id="getmore" style="font-size:.24rem;text-align: center;color:#888;padding:.25rem .24rem .4rem; clear:both">
        <a href="javascript:void(0)" onClick="ajax_sourch_submit()">点击加载更多</a>
    </div>
    {/notempty}
    <div class="liuyandom"> 
      <section class="innercontent1">
        <div  >
          <div>
            <div class="form_search"><span>留言类型：</span>
            <div class="anniu">
	            <ul>
	              <li class="on">
	              	<label for="msg_type0"><input type="radio" name="msg_type" value="0" checked="checked" class="radio" id="msg_type0"> 留言</label>
	              </li>
	              <li>
	              	<label for="msg_type1"><input type="radio" name="msg_type" value="1" class="radio" id="msg_type1">投诉</label>
	              </li>
	              <li>
	              	<label for="msg_type2"> <input type="radio" name="msg_type" value="2" class="radio" id="msg_type2">询问</label>
	              </li>
	              <li>
	              	<label for="msg_type3"><input type="radio" name="msg_type" value="3" class="radio" id="msg_type3">售后</label>
	              </li>
	              <li>
	              	<label for="msg_type4"> <input type="radio" name="msg_type" value="4" class="radio" id="msg_type4">求购</label>
	              </li>
	             </ul>
             </div>
            </div>
          </div>
          <label for="msg_title">
          <div class="field_else">
          <span>留言主题：</span>
              <input type="text" name="msg_title" id="msg_title" placeholder="*主题"/>
          </div>
          </label>
          <div class="field_else">
              <label for="msg_content"> 
              <span>留言内容：</span>
               <textarea name="msg_content" id="msg_content" style="height:100px;"></textarea>
              </label>
          </div>
          <div class="field_else">
          <span>验证码：</span>
          <img class="po-ab to0" id="verify_code_img" width="120" height="40" src="{:captcha_src('admin_login')}"  onclick="this.src=this.src" />
          <input style="margin-top:20px" type="text" name="verify_code" id="verify_code" placeholder="验证码"/>
                            
          </div>
        </div>
          <div style=" padding-bottom:10px;">
              <button  onclick="message_list()" class="btn_big1 ">提交留言</button>
          </div>

      </section>
    </div>
</div>
</div>
    {include file="common/bar"}
</body>
{/block}

{block name="js"}

<script>
    /* 加载更多*/
    var  page = 1;
    function ajax_sourch_submit()
    {
        page += 1;
        $.ajax({
            type : "get",
            url:"{:url('User/message_list')}",
            data : {page:page},
            success: function(data)
            {
                if($.trim(data) == '')
                    $('#getmore').hide();
                else
                    $(".liuyan_list").append(data);
            }
        });
    }
	
$('.anniu ul li').click(function(){
	$(this).find("input").attr("checked","checked");
	$('.anniu ul li').removeClass("on");
	$(this).addClass("on");
})


//提交留言
function message(){
    if ($('#msg_title').val().length == 0) {
        layer.open({content:'留言标题不能为空',time:2});
        return false
    }
    if ($('#msg_content').val().length == 0) {
        layer.open({content:'留言内容不能为空',time:2});
        return false
    }
    if ($('#msg_title').val().length > 100) {
        layer.open({content:'标题不能超过100字符',time:2});
        return false
    }
    if ($('#verify_code').val().length == 0) {
        layer.open({content:'验证码不能为空',time:2});
        return false
    }
    return true;
}
function message_list() {
    if (message()==true){
        $.post("{:url('User/message_list')}",{msg_type:$('input:radio:checked').val(), msg_title:$('#msg_title').val(), verify_code:$('#verify_code').val(), msg_content:$('#msg_content').val()}, function(ret){
            if(ret.code != 200){
                layer.open({content:ret.msg,time:0.5});
                return false;
            }
            location.href = "{:url('User/message_list')}";
        });
    }
    return false;
}

</script>
{/block}